package impl;

import impl.ui.MainWindow;
import impl.ui.ParametersWindow;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import classes.Constants;
import classes.Utils;

public class Main {
	private static final String TAG = Constants.TAG + "." + Main.class.getSimpleName();

	public static void main(String[] args) {
		final ParametersWindow params = new ParametersWindow();
		params.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent arg0) {
				super.windowClosed(arg0);
				
				// Get parameters from window
				int r = params.getRobotsNumber();
				int c = params.getCandiesNumber();
				Utils.logC(TAG, "R: " + r + " C: " + c);
				
				// Start CandyWorld and UI
				new MainWindow(c, r, (new CandyWorldImpl(c, r, Constants.MAP_WIDTH, Constants.MAP_HEIGHT)).newComponent());
			}
		});
	}
}
